package com.study.controller.FDcontroller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.study.model.pojo.FDpojo.Finance;
import com.study.model.pojo.FDpojo.PurchasePayment;
import com.study.service.FDservice.PurchasePaymentServices;

@CrossOrigin
@Controller
public class PurchasePaymentController {

	@Autowired
	PurchasePaymentServices pps;

	/**
	 * 获取所有采购付款信息
	 * 
	 * @return
	 */
	// 访问地址：http://localhost:8089/all_PurchasePayment
	@GetMapping("/all_PurchasePayment")
	@ResponseBody // 将List集合以JSON数组的形式返回，页面不跳转
	public List<PurchasePayment> allPurchasePayment() {
		System.out.println("123444");
		return pps.selectAllpp();
	}

//	@RequestMapping("/changefstate")
//	@ResponseBody
////	public String changefinancestate(@RequestBody Map<String, String> map) {
//	public String changefinancestate(String purorderid, String financestate) {
//		int fstate = Integer.parseInt(financestate);
//		if (pps.audit(purorderid,fstate)) {
//			System.out.println("状态改变...+++");
//		} else {
//			System.out.println("NONO...+++");
//		}
//		System.out.println("编号："+purorderid + "，状态：" + financestate);
//		return purorderid;
//	}
//	public String changefinancestate(@RequestBody Map<String, String> map) {	
	@RequestMapping("/changefstate")
	@ResponseBody
	public String changefinancestate(String purorderid, String financestate, String remarks) {
		System.out.println("编号：" + purorderid + "，状态：" + financestate + ", 备注：" + remarks);
		int fstate = Integer.parseInt(financestate);
		if (pps.audit(purorderid, fstate, remarks)){
			System.out.println("状态改变...+++");
		} else {
			System.out.println("NONO...+++");
		}
		System.out.println("编号：" + purorderid + "，状态：" + financestate);
		return purorderid;
	}
}
